package com.zhousb.deviceManager.controller;

import com.zhousb.deviceManager.common.R;
import com.zhousb.deviceManager.common.ResponseResult;
import com.zhousb.deviceManager.model.vo.AuthVo;
import com.zhousb.deviceManager.model.dto.LoginDto;
import com.zhousb.deviceManager.service.LoginService;
import com.zhousb.deviceManager.service.SysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
@Tag(name = "用户认证")
public class AuthController {

    @Resource
    LoginService loginService;

    @Resource
    private SysUserService sysUserService;

    @PostMapping("/login")
    public ResponseResult<AuthVo> login(@RequestBody LoginDto dto) {
        return R.success(loginService.login(dto));
    }

    @PostMapping("/logout")
    public ResponseResult logout() {
        return R.success();
    }

    @GetMapping("/codes")
    @Operation(summary = "获取当前用户按钮权限列表")
    public ResponseResult listUserAccessCodes(){
        return R.success(sysUserService.listUserAccessCodes());
    }
}
